
function getNetwork(pageNo) {//获取商品列表数据
    let startNum=pageNo*20
    $.ajax({
        url: 'http://www.xiongmaoyouxuan.com/api/column/3183/items?start='+startNum,
        type: 'get',
        success: function (res) {
            showProduct(res.data.list)
        },
        error: function (error) {
            alert('网络错误')
        }
    })
}

let listAll=[]//用于拼接数据
function showProduct(ProductList) {//渲染商品列表
    listAll=[...listAll,...ProductList]
    let arr = listAll.map(item => {
        return `
        <li class="pro-item" onclick="onDetail(${item.id})">
            <img src="${item.image}">
            <p>${item.title}</p>
            <div class="pro-merchant">
                <span class="left">天猫</span>
                <span class="right">包邮</span>
            </div>
            <div class="pro-sales">
                <span class="left-money">￥</span>
                <span class="left">${item.price}</span>
                <span class="right">${item.saleNum}人已买</span>
                <span class="tickt">${item.couponValue}</span>
        </div>
        `
    })
    let str = arr.join('')
    $('#fixedList>ul').html(str)
}

function onLoadMore() {
    let pageNo = 1
    getNetwork(pageNo)
    $('.SeeMore>div').on('click', function () {
        getNetwork(++pageNo)
    })
}

function onDetail(id) {
    location.href='./datetil.html?id='+id
}

onLoadMore()

function outputTop() {    //回到顶部
    let i = document.documentElement.scrollTop
    let timer = setInterval(function () {
        i=i-20
        if (i <= 0) {
            clearInterval(timer)
            
        }
        document.documentElement.scrollTop = i
    }, 1)
}

window.onscroll = function () {    
console.log('浏览器');
let i = document.documentElement.scrollTop
console.log(i);
if (i <= 0) {
    $('#return').css('display','none')        
} else {
    $('#return').css('display','block')        
}
}